home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
libs
/
tlp4v11c
/
docu
/
uniinp.txt
< prev
next >
Wrap
Text File
|
1994-05-22
|
11KB
|
345 lines
uniinp.obj function summary:
============================
This list contains UNIX-like summaries for the routines that
are currently contained in uniinpx.obj.
uniinpx.obj is intended for use with the tgdlp4xx.obj ModeX
graphics driver. However this library could also act as a stand
alone module. In order for uniinpx.obj to work the following
hardware items are required:
- IBM compatible AT with 80286 CPU or above
- MF-II keyboard
- any VGA card
uniinpc.obj is assembled for the COMPACT memory model. This
means that all calls to procedures must be declared as NEAR
while pointers to data are all FAR.
uniinpl.obj is assembled for the LARGE memory model. In this
model all calls to procedures as well as all pointers to data
are to be declared as FAR.
uniinpx.obj expects all parameters to be passed using C calling
conventions. The C calling mechanism is described in tgdlp4.txt.
PART I: KEYBOARD FUNCTIONS
----------------------------------------------------------------
byte getkeyboard(void);
install uniinp keyboard interrupt handler
FUNCTION:
In order for the functions lastkey(), keystatus() and
freekeyboard() to work the system keyboard handler has to be
replaced by the uniinp keyboard handler. This is done when
calling getkeyboard(). The uniinp keyboard handler never calls
the default system keyboard handler - giving you TOTAL control
over the keyboard. That means if you don't implement it the user
can't even reset her/his AT using Ctrl-Alt-Del.
Note: You should call keyboardled(0) BEFORE getkeyboard() to
assure proper function of the lastkey() and keystatus() routines.
INPUTS:
none
RESULT:
byte success: TRUE if the uniinp keyboard handler was
successfully installed,
FALSE if not (i.e. the uniinp keyboard handler is
already active).
BUGS:
none known
SEE ALSO:
freekeyboard(), lastkey(), keystatus(), keyboardled()
byte freekeyboard(void);
uninstall uniinp keyboard interrupt handler
FUNCTION:
Once the uniinp keyboard [lastkey(), keystatus()] services
aren't required anymore the uniinp keyboard interrupt server
should be removed and the default BIOS keyboard handler should
be re-installed. To accomplish this just call freekeyboard()
which returns the keyboard control to the system.
Note: You should call keyboardled(sysled()) AFTER freekeyboard()
to restore the old keyboard LED state (if you have changed it).
INPUTS:
none
RESULT:
byte success: TRUE if the keyboard was successfully returned to
the system,
FALSE if not (i.e. the uniinp keyboard handler was
not active)
BUGS:
none known
SEE ALSO:
getkeyboard()
ubyte lastkey(void);
get uniinp scan code of the key that was pressed/released last
FUNCTION:
To find out which key was pressed or released last call this
procedure. It will return the uniinp keycode of the last used
key or 0 if you have already queried the last key or no key was
used since the initialization of the uniinp keyboard handler.
The uniinp keycode is the MF-II scan code of the key if the key
represents a non special character. For example the key 't'
returns scan code 20. If a special key was hit/released the
uniinp keycode of that key is the second byte of the MF-II scan
code + 128. Example: The cursor right key would return 77+128=
205. To check if a specific key was pressed or released call
keystatus() with the uniinp keycode as parameter.
INPUTS:
none
RESULT:
ubyte keycode: uniinp keycode of the key that was in use last or
0 if that key was already queried.
BUGS:
none known
SEE ALSO:
keystatus()
byte keystatus(ubyte keycode);
return status of specified key
FUNCTION:
This routine returns TRUE if the key of which the uniinp keycode
was passed in keycode is currently held down. It returns FALSE
if this key is currently not pressed. To find out which key was
used last call the lastkey() procedure.
INPUTS:
keycode: uniinp keycode of the key of which the status should be
checked
RESULT:
byte keypressed: TRUE if the key is currently pressed,
FALSE if not.
BUGS:
none known
SEE ALSO:
lastkey()
byte keyboardled(ubyte ledstatus);
control for the MF-II keyboard LEDs/state
FUNCTION:
keyboardled() allows you to switch on/off the LEDs on a MF-II
keyboard:
bit 0 of ledstatus controls the scroll-lock LED
bit 1 of ledstatus controls the num-lock LED
bit 2 of ledstatus controls the caps-lock LED
Switch on/off a specific LED by setting/resetting the
corresponding bit in ledstatus. Setting/resetting the LED bits
has effects on the key scan code that the keyboard returns to
the computer. For proper function of the lastkey() and
keystatus() procedures it is recommended to switch all keyboard
LEDs off to force the MF-II keyboard to produce 'native' scan
codes.
keyboardled() doesn't use a BIOS routine to set/clear the
LEDs. Therefore when returning from your program you should set
the old BIOS keyboard LED state. To do this, just call
keyboardled(sysled());
keyboardled() should be called before getkeyboard() or after
freekeyboard().
INPUTS:
ledstatus: LED status variable:
bit 0 controls the scroll-lock LED
bit 1 controls the num-lock LED
bit 2 controls the caps-lock LED
to switch on a LED set the corresponding LED bit.
to switch off a LED clear the corresponding LED bit.
RESULT:
byte success: TRUE if the keyboard accepted the new LED settings,
FALSE if not.
BUGS:
none known
SEE ALSO:
lastkey(), keystatus(), sysled(), getkeyboard(), freekeyboard()
byte keyboardtyp(ubyte kbddelay,ubyte kbdtypem);
control for the MF-II keyboard delay and typematic rates
FUNCTION:
Using this procedure you can change the MF-II keyboard delay and
typematic rates. The keyboard delay rate represents the period
of time that passes between a key being first holded down and
the key being repeated. You can choose one of these values for
the keyboard delay rate, which must be passed in kbddelay:
value delay rate
0 .25 sec
1 .5 sec
2 .75 sec
3 1.0 sec
The keyboard typematic rate must be adjusted simultaneously to
the keyboard delay rate and vice versa. The typematic rate is
the number of repetitions per second of a keycode the keyboard
sends after the keyboard delay time has passed. The keyboard
typematic rate is a 5 bit value - hence allowing you to pass
0-31 as kbdtypem parameter. The value 0 sets the key repeat rate
to 30 times per second while the value 31 sets the key repeat
rate to only 2 times per second.
Once keyboardtyp() is called there is no way to set the previous
keyboard delay / typematic rates that were active before calling
this function. keyboardtyp() should only be called before
getkeyboard() / after freekeyboard().
INPUTS:
kbddelay: keyboard delay rate. Allowed values are between 0-3
(equals a delay of 0.25 - 1.0 sec before key repetition
begins).
kbdtypem: keyboard repeat rate. Allowed values are between 0-31
(equals a key repeat rate of 30 - 2 times a second).
RESULT:
byte success: TRUE if the keyboard accepted the new delay /
typematic rates,
FALSE if not.
BUGS:
none known
SEE ALSO:
getkeyboard(). freekeyboard()
ubyte sysled(void);
query the BIOS MF-II keyboard LED values
FUNCTION:
In combination with keyboardled() this routine allows setting
the keyboard LEDs as expected to be set by the BIOS. Usefull
when the LED bits were previously changed using keyboardled()
[to i.e. receive proper key scan codes with the lastkey() and
keystatus() procedures]. Just call keyboardled(sysled()) to
set the old BIOS LED state.
INPUTS:
none
RESULT:
ubyte ledstatus: keyboard LED state which the BIOS expects to be
set.
BUGS:
none known
SEE ALSO:
keyboardled()
PART II: JOYSTICK FUNCTIONS
----------------------------------------------------------------
joypos far *readstick(ubyte stick);
read position(s) of connected joystick(s)
FUNCTION:
To make use of this procedure you first have to check which
joystick(s) are connected. Call readstick(1) [readstick(2)] to
see if joystick #0 [joystick #1] is connected. If joystick #0
[#1] is not attached readstick() will return FALSE - otherwise
the specified joystick is connected and the function will return
a pointer to the joystick position structure which looks like
this:
struct { uword joy0xpos,joy0ypos;
uword joy1xpos,joy1ypos;
} joypos;
joy0xpos contains the current x position of joystick #0
joy0ypos contains the current y position of joystick #0
joy1xpos contains the current x position of joystick #1
joy1ypos contains the current y position of joystick #1
joystick x,y position values usually range from 0-31 (tested with
Gravis Gamepad/ Gravis Analog joysticks). The joystick position
values returned by readstick() are CPU speed independent.
Notes: a) the values of joy0xpos,joy0ypos [joy1xpos,joy1ypos]
are undefined when readstick(2) [readstick(1)] was
called.
b) use readstick(3) to query the joystick positions of
both joysticks simultaneously. This is twice as fast
than a calling combination of readstick(1) and
readstick(2).
WARNING: use readstick(3) only when both joysticks are
REALLY connected - otherwise readstick(3) will return
FALSE.
c) It is not allowed to call readstick() while a vertical
retrace is active. Do a waittof() before using this
routine.
INPUTS:
stick: indicator of which joystick position should be queried:
if bit 0 is set readstick() reads the position of
joystick #0.
if bit 1 is set readstick() reads the position of
joystick #1.
RESULT:
joypos *: pointer to a structure containing the requested
joystick position(s). The structure looks like this:
struct { uword joy0xpos,joy0ypos;
uword joy1xpos,joy1ypos;
} joypos;
joypos * is FALSE if the queried joystick is not
connected.
BUGS:
none known
SEE ALSO:
readjbutton()
ubyte readjbutton(void);
read joystick button status
FUNCTION:
Query the states of the joystick buttons with readjbutton(). The
lower four bits that are returned in the result ubyte can be
ignored. The button status of the joystick(s) is stored in the
upper four bits:
bit 4 represents joystick #0 button #0
bit 5 represents joystick #0 button #1
bit 6 represents joystick #1 button #0
bit 7 represents joystick #1 button #1
If a joystick button is pressed the corresponding bit is 0 -
else it is 1.
INPUTS:
none
RESULT:
ubyte buttons: button status of connected joystick(s)
BUGS:
none known
SEE ALSO:
readstick()